#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <stdlib.h>


typedef char BTreeDataType;

typedef struct BTreeNode
{
	struct BTreeNode* left;
	struct BTreeNode* right;
	BTreeDataType val;
}BTreeNode;

BTreeNode* BuyBTreeNode(BTreeDataType x)
{
	BTreeNode* node = (BTreeNode*)malloc(sizeof(BTreeNode));
	if (node == NULL)
	{
		perror("malloc");
		return NULL;
	}
	node->val = x;
	node->left = NULL;
	node->right = NULL;
	return node;
}

BTreeNode* CreateBTree(char* str, int* pi)
{
	//abc##de#g##f###
	if (str[*pi] == '#')
	{
		(*pi)++;
		return NULL;
	}
	BTreeNode* root = BuyBTreeNode(str[*pi]);
	(*pi)++;
	root->left = CreateBTree(str, pi);
	root->right = CreateBTree(str, pi);
	return root;
}

void InOrder(BTreeNode* root)
{
	if (root == NULL)
	{
		return;
	}
	InOrder(root->left);
	printf("%c ", root->val);
	InOrder(root->right);
}

int main()
{
	char a[100] = { 0 };
	scanf("%s", a);
	int i = 0;
	BTreeNode* root = CreateBTree(a,&i);
	InOrder(root);
	return 0;
}